package 面向对象.testSeven;

import java.io.*;

public class CopyFile2_2 {
    public static void main(String[] args) throws Exception{
        File file = new File("D:\\Program Files\\JetBrains\\IntelliJ IDEA 2021.2.3\\MyProject_JAVA\\IdeaProjects\\狂神说Java\\src\\base\\Demo01.java");
        FileInputStream fileInputStream = new FileInputStream(file);
        FileReader fileReader = new FileReader(file);

        FileOutputStream fileOutputStream = new FileOutputStream("D:\\Program Files\\JetBrains\\IntelliJ IDEA 2021.2.3\\MyProject_JAVA\\IdeaProjects\\idea-cu\\src\\面向对象\\testSeven\\copyfile1.txt");
        FileWriter fileWriter = new FileWriter("D:\\Program Files\\JetBrains\\IntelliJ IDEA 2021.2.3\\MyProject_JAVA\\IdeaProjects\\idea-cu\\src\\面向对象\\testSeven\\" +
                "copyfile2.txt");

        int b;
        while ((b=fileInputStream.read()) != -1) {
            System.out.print((char) b);
            fileOutputStream.write((char) b);
        }
        fileInputStream.close();

        System.out.println("========================================================");
        int c;
        while ((c=fileReader.read()) != -1) {
            System.out.print((char) c);
            fileWriter.write(c);
            fileWriter.flush();
        }
        fileWriter.close();
    }
}
